<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @category    design
 * @package     default_default
 * @copyright   Copyright (c) 2010 Magento Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<?php $_order = $this->getOrder() ?>
<?php
$orderAdminDate = $this->formatDate($_order->getCreatedAtDate(), 'medium', true);
$orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium', true);
?>
<div class="box-left">
    <!--Order Information-->
    <div class="entry-edit">
        <?php if ($_order->getEmailSent()):
            $_email = Mage::helper('sales')->__('the order confirmation email was sent');
        else:
            $_email = Mage::helper('sales')->__('the order confirmation email is not sent');
        endif; ?>
        <div class="entry-edit-head">
        <?php if ($this->getNoUseOrderLink()): ?>
            <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?> (<?php echo $_email ?>)</h4>
        <?php else: ?>
            <a href="<?php echo $this->getViewUrl($_order->getId()) ?>"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?></a>
            <strong>(<?php echo $_email ?>)</strong>
        <?php endif; ?>
        </div>
        <div class="fieldset">
            <table cellspacing="0" class="form-list">
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date') ?></label></td>
                <td><strong><?php echo $orderAdminDate ?></strong></td>
            </tr>
            <?php if ($orderAdminDate != $orderStoreDate):?>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date (%s)', $_order->getCreatedAtStoreDate()->getTimezone()) ?></label></td>
                <td><strong><?php echo $orderStoreDate ?></strong></td>
            </tr>
            <?php endif;?>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('Order Status') ?></label></td>
                <td><strong><span id="order_status"><?php echo $_order->getStatusLabel() ?></span></strong></td>
            </tr>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('Purchased From') ?></label></td>
                <td><strong><?php echo $this->getOrderStoreName() ?></strong></td>
            </tr>
            <?php if($_order->getRelationChildId()): ?>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('Link to the New Order') ?></label></td>
                <td><a href="<?php echo $this->getViewUrl($_order->getRelationChildId()) ?>">
                    <?php echo $_order->getRelationChildRealId() ?>
                </a></td>
            </tr>
            <?php endif; ?>
            <?php if($_order->getRelationParentId()): ?>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('Link to the Previous Order') ?></label></td>
                <td><a href="<?php echo $this->getViewUrl($_order->getRelationParentId()) ?>">
                    <?php echo $_order->getRelationParentRealId() ?>
                </a></td>
            </tr>
            <?php endif; ?>
            <?php if($_order->getRemoteIp()): ?>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('Placed from IP') ?></label></td>
                <td><strong><?php echo $_order->getRemoteIp(); echo ($_order->getXForwardedFor())?' (' . $_order->getXForwardedFor() . ')':''; ?></strong></td>
            </tr>
            <?php endif; ?>
            <?php if($_order->getGlobalCurrencyCode() != $_order->getBaseCurrencyCode()): ?>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('%s / %s rate:', $_order->getGlobalCurrencyCode(), $_order->getBaseCurrencyCode()) ?></label></td>
                <td><strong><?php echo $_order->getBaseToGlobalRate() ?></strong></td>
            </tr>
            <?php endif; ?>
            <?php if($_order->getBaseCurrencyCode() != $_order->getOrderCurrencyCode()): ?>
            <tr>
                <td class="label"><label><?php echo Mage::helper('sales')->__('%s / %s rate:', $_order->getOrderCurrencyCode(), $_order->getBaseCurrencyCode()) ?></label></td>
                <td><strong><?php echo $_order->getBaseToOrderRate() ?></strong></td>
            </tr>
            <?php endif; ?>
            </table>
        </div>
    </div>
</div>
<div class="box-right">
    <!--Account Information-->
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Account Information') ?></h4>
        </div>
        <div class="fieldset">
            <div class="hor-scroll">
                <table cellspacing="0" class="form-list">
                <tr>
                    <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Name') ?></label></td>
                    <td>
                    <?php if ($_customerUrl=$this->getCustomerViewUrl()) : ?>
                        <a href="<?php echo $_customerUrl ?>" target="_blank"><strong><?php echo $this->htmlEscape($_order->getCustomerName()) ?></strong></a>
                    <?php else: ?>
                        <strong><?php echo $this->htmlEscape($_order->getCustomerName()) ?></strong>
                    <?php endif; ?>
                    </td>
                </tr>
                <tr>
                    <td class="label"><label><?php echo Mage::helper('sales')->__('Email') ?></label></td>
                    <td><a href="mailto:<?php echo $_order->getCustomerEmail() ?>"><strong><?php echo $_order->getCustomerEmail() ?></strong></a></td>
                </tr>
                <?php if ($_groupName=$this->getCustomerGroupName()) : ?>
                <tr>
                    <td class="label"><label><?php echo Mage::helper('sales')->__('Customer Group') ?></label></td>
                    <td><strong><?php echo $_groupName ?></strong></td>
                </tr>
                <?php endif; ?>
                <?php if ($_dob=$this->getOrder()->getCustomerDob()) : ?>
                <tr>
                    <td class="label"><label><?php echo Mage::helper('sales')->__('Date of Birth') ?></label></td>
                    <td><strong><?php echo Mage::helper('core')->formatDate($_dob, 'medium') ?></strong></td>
                </tr>
                <?php endif; ?>                
                </table>
            </div>
        </div>
    </div>
</div>
<div class="clear"></div>

<div class="box-left">
    <!--Billing Address-->
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-billing-address"><?php echo Mage::helper('sales')->__('Billing Address') ?></h4>
        </div>
        <fieldset id="billing-static">
            <address id="billing-static-text"><?php echo $_order->getBillingAddress()->getFormated(true); ?>
            </address>
        </fieldset>
        
        
        <fieldset id="billing-edit-form" style="display:none;">
        	<?php $billing = $_order->getBillingAddress() ?>

        	<form id="billing-fields">
        		
        		<input type="hidden" name="type" value="billing" />
        		<input type="hidden" name="admin_user" value="<?php echo Mage::getSingleton('admin/session')->getUser()->getUsername() ?>" />
        		<input type="hidden" name="entity_id" value="<?php echo $billing->getId() ?>" />
		        <div class="admin-widget-edit-fields"><label>First Name:</label><input type="text" class=" input-text" name="firstname" value="<?php echo $billing->getFirstname() ?>" /></div>
		        <div class="admin-widget-edit-fields"><label>Last Name:</label> <input type="text" class=" input-text" name="lastname" value="<?php echo $billing->getLastname() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>Company:</label> <input type="text" class=" input-text" name="company" value="<?php echo $billing->getCompany() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>Address 1:</label> <input type="text" class=" input-text" name="street1" value="<?php echo $billing->getStreet1() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>Address 2:</label> <input type="text" class=" input-text" name="street2" value="<?php echo $billing->getStreet2() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>City:</label> <input type="text" class=" input-text" name="city" value="<?php echo $billing->getCity() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>State:</label> 
				
				<select name="region_id" id="billing:region_id" style="display:none;">
                </select>
 <input type="text" id="billing:region" name="region" value="<?php echo $this->htmlEscape($billing->getRegion()) ?>"  title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
				</div>
			<div class="admin-widget-edit-fields"><label>Postcode:</label> <input class=" input-text" type="text" name="postcode" value="<?php echo $billing->getPostcode() ?>" /></div>
			<div class="admin-widget-edit-fields"><label>Country:</label> 
                   <?php echo $this->getCountryHtmlSelect('billing') ?>  
           </div>
			<div class="admin-widget-edit-fields"><label>Phone:</label> <input type="text" class=" input-text" name="telephone" value="<?php echo $billing->getTelephone() ?>" /></div>
			</form>
        </fieldset>
 <script type="text/javascript">
        //<![CDATA[
             new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
            // $('billing:country_id').onchange();
        //]]>
        </script>
    </div>
</div>
<?php if (!$this->getOrder()->getIsVirtual()): ?>
<div class="box-right">
    <!--Shipping Address-->
    <div class="entry-edit">
        <div class="entry-edit-head">
            <h4 class="icon-head head-shipping-address"><?php echo Mage::helper('sales')->__('Shipping Address') ?></h4>
        </div>
        <fieldset id="shipping-static">
            <address id="shipping-static-text">
            <?php echo $_order->getShippingAddress()->getFormated(true) ?>
            <?php if ($_taxvat = $_order->getCustomerTaxvat()):?>
                <br>
                 <?php echo Mage::helper('sales')->__('TAX/VAT Number') ?> :
                 <strong><?php echo $this->htmlEscape($_taxvat)?></strong>
                <?php endif;?>
            </address>
        </fieldset>
        
        
        <fieldset id="shipping-edit-form" style="display:none;">
        	<?php $shipping = $_order->getShippingAddress() ?>
			
        	<form id="shipping-fields">
        		<input type="hidden" name="type" value="shipping" />
        		<input type="hidden" name="admin_user" value="<?php echo Mage::getSingleton('admin/session')->getUser()->getUsername() ?>" />
        		<input type="hidden" name="entity_id" value="<?php echo $shipping->getId() ?>" />
		        <div class="admin-widget-edit-fields"><label>First Name:</label> <input type="text" class=" input-text" name="firstname" value="<?php echo $shipping->getFirstname() ?>" /></div>
		        <div class="admin-widget-edit-fields"><label>Last Name:</label> <input type="text" class=" input-text" name="lastname" value="<?php echo $shipping->getLastname() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>Company:</label> <input type="text" class=" input-text" name="company" value="<?php echo $shipping->getCompany() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>Address 1:</label> <input type="text" class=" input-text" name="street1" value="<?php echo $shipping->getStreet1() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>Address 2:</label> <input type="text" class=" input-text" name="street2" value="<?php echo $shipping->getStreet2() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>City:</label> <input type="text" class=" input-text" name="city" value="<?php echo $shipping->getCity() ?>" /></div>
				<div class="admin-widget-edit-fields"><label>State:</label> <select name="region_id" id="shipping:region_id">
                </select>
 <input type="text" id="shipping:region" name="region" value="<?php echo $this->htmlEscape($shipping->getRegion()) ?>"  title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
              </div>
				<div class="admin-widget-edit-fields"><label>Postcode:</label> <input type="text" id="ship-zip" class=" input-text" name="postcode" value="<?php echo $shipping->getPostcode() ?>" /></div>
                <div class="admin-widget-edit-fields"><label>Country:</label>
                   <?php echo $this->getCountryHtmlSelect('shipping') ?>  
                </div>
				<div class="admin-widget-edit-fields"><label>Phone:</label> <input type="text" class=" input-text" name="telephone" value="<?php echo $shipping->getTelephone() ?>" /></div>
				

		</form>
        </fieldset>
 <script type="text/javascript">
        //<![CDATA[
             new RegionUpdater('shipping:country_id', 'shipping:region', 'shipping:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
            // $('billing:country_id').onchange();
        //]]>
        </script>
    </div>
</div>
<div class="clear"></div>
<?php endif; ?>
